<?php

/**
 * This is the model class for table "Disciplina_Carga_Recurso".
 *
 * The followings are the available columns in table 'Disciplina_Carga_Recurso':
 * @property string $ID_DISCIPLINA_CARGA
 * @property integer $ID_RECURSO
 * @property integer $NU_QUANTIDADE
 */
class Disciplina_Carga_Recurso extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return Disciplina_Carga_Recurso the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'Disciplina_Carga_Recurso';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('ID_DISCIPLINA_CARGA, ID_RECURSO, NU_QUANTIDADE', 'required'),
            array('ID_RECURSO, NU_QUANTIDADE', 'numerical', 'integerOnly' => true),
            array('ID_DISCIPLINA_CARGA', 'length', 'max' => 20),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('ID_DISCIPLINA_CARGA, ID_RECURSO, NU_QUANTIDADE', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'iD_RECURSO' => array(self::BELONGS_TO, 'Recurso', 'ID_RECURSO'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'ID_DISCIPLINA_CARGA' => 'Id Disciplina Carga',
            'ID_RECURSO' => 'Id Recurso',
            'NU_QUANTIDADE' => 'Nu Quantidade',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('ID_DISCIPLINA_CARGA', $this->ID_DISCIPLINA_CARGA, true);

        $criteria->compare('ID_RECURSO', $this->ID_RECURSO);

        $criteria->compare('NU_QUANTIDADE', $this->NU_QUANTIDADE);

        return new CActiveDataProvider('Disciplina_Carga_Recurso', array(
                    'criteria' => $criteria,
                ));
    }

}